package com.housekeeping.housekeeping.advertisingmanagement.utils;

import java.io.Serializable;

public class ResponseEntitys<T> implements Serializable {
    private Integer code;//代码
    private String msg;//信息
    private Integer pageNum;//页数
    private T data;//数据
    private int status;//状态值
    public ResponseEntitys() {
    }

/*    public ResponseEntitys(Integer status ,Integer code, String msg) {
        this.status = status;
        this.code = code;
        this.msg = msg;
    }*/
    /** 下面的成功和失败是新增的
     * 成功
     * @param data
     * @param <T>
     * @return
     */
    public static <T> ResponseEntitys<T> success(T data) {
        ResponseEntitys<T> entity = new ResponseEntitys<>();
        entity.setData(data);
        entity.setStatus(200);
        entity.setMsg("success");
        return entity;
    }
    //失败
    public static <T> ResponseEntitys<T> error(com.housekeeping.housekeeping.order.utils.ResponseCode orderSearchError) {
        return error(404, "error");
    }

    public static <T> ResponseEntitys<T> error(int status, String msg) {
        ResponseEntitys<T> entity = new ResponseEntitys<>();
        entity.setStatus(status);
        entity.setMsg(msg);
        return entity;
    }

    public static <T> ResponseEntitys<T> error(ResponseCode responseCode) {
        ResponseEntitys<T> entity = new ResponseEntitys<>();
        entity.setStatus(responseCode.getStatus());
        entity.setMsg(responseCode.getMsg());
        return entity;
    }


    public Integer getPageNum() {
        return pageNum;
    }

    public void setPageNum(Integer pageNum) {
        this.pageNum = pageNum;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
    //新增的状态值的get() set()
    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }
}
